package org.tbwork.utility.toolbox;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

public class tbDebugTools {

	
	/** 测试时使用，把文本写入本地文件 C://testout.txt
	 * @param s 文本
	 * @return 成功返回true
	 */
	public static boolean WriteToFile(String s)
	{
		  FileWriter fw = null;
		  File f = new File("C://testout.txt");

		   try {
		    if(!f.exists()){
		     f.createNewFile();
		    }
		    fw = new FileWriter(f);
		    BufferedWriter out = new BufferedWriter(fw);
		    out.write(s, 0, s.length()-1);
		    out.close();
		    return true;
		   } catch (IOException e) {
		    e.printStackTrace();
		   }
		   return false; 
	}
	

	/**  测试时使用，把文本写入本地文件
	 * @param s  待写入文本
	 * @param filePath 目标文件路径+文件名, 如  C://1.txt
	 * @return 成功返回true
	 */
	public static boolean WriteToFile(String s,String filePath)
	{

		  FileWriter fw = null;
		  File f = new File(filePath);

		   try {
		    if(!f.exists()){
		     f.createNewFile();
		    }
		    fw = new FileWriter(f);
		    BufferedWriter out = new BufferedWriter(fw);
		    out.write(s, 0, s.length()-1);
		    out.close();
		    return true;
		   } catch (IOException e) {
		    e.printStackTrace();
		   }
		   return false; 
	}
}
